int findMajorityElement(std::vector<int> A) 
{
	int majority_element = A[0] ;
	int count  = 1;

	for ( unsigned int i = 1 ; i < A.size() ; ++i) 
	{   
		A[i] == majority_element ?  ++count : --count;     
		if ( count == 0) 
		{
		   majority_element  = A[i];     
		   count = 1;
		}      
	}      
	return majority_element;  
}

int findaMajorityExpensive(std::vector<int> A)
{
    int majorityElement  = A[0];
    unsigned int frequency = 0; 

    for( unsigned int i = 0; i < A.size() ; ++i) 
    {
		frequency = 0; 
		for( unsigned int j=0 ; i <A.size() ; ++i) 
		{
			if(A[j] == A[i] )
			{
			   ++frequency; 
			   if(frequency > A.size()/2)
			   {
					return A[i] ; 
			   }
			}
		}
	} 
	return -1;
}
int main()
{
   std::vector<int> A; 
   A.push_back(1);
   A.push_back(1);   A.push_back(1);   A.push_back(1);   A.push_back(1);   A.push_back(1);
   A.push_back(2);   A.push_back(2);   A.push_back(3);   A.push_back(3);   A.push_back(4);   

    cout<<findMajorityElement(A); 
}